package com.zzedu.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zzedu.domain.ZzSubjectContent;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.Map;

/**
 * 题目内容Mapper接口
 *
 * @author Mr.Wang
 * @date 2025-04-12
 */
public interface ZzSubjectContentMapper extends BaseMapper<ZzSubjectContent> {

    /**
     * 获取 提交数据
     *
     * @param page
     * @param start
     * @param end
     * @return
     */
    @Select({
            "<script>",
            "SELECT DISTINCT e.picture_book_id, e.student_id, p.unit_id",
            "FROM zz_exercise_book e",
            "INNER JOIN zz_picture_book p ON e.picture_book_id = p.id",
            "WHERE e.deleted = 0",
            "AND p.deleted = 0 AND p.review_flag = 0",
            "AND e.gmt_create BETWEEN #{start} AND #{end}",
            "ORDER BY e.picture_book_id ASC",
            "</script>"
    })
    IPage<Map<String, Object>> getSubmitDataByDate(IPage page,
                                                   @Param("start") LocalDateTime start,
                                                   @Param("end") LocalDateTime end);
}
